﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

namespace MoreMountains.CorgiEngine
{
    public class SaveAblityEvent : MonoBehaviour
    {
        //  记录下来的事件
        private Action SavedHandleEvent;

        //  是否可以记录
        private bool _recording = false;

        public void StartRecord()
        {
            SavedHandleEvent = null;
            _recording = true;
        }
        public void CloseRecord()
        {
            _recording = false;
        }

        public void SetSavedEvent(Action event_)
        {
            if (_recording)
            {
                SavedHandleEvent = event_;
            }
        }

        public void InvokeSavedEvent()
        {
            if (null != SavedHandleEvent)
            {
                SavedHandleEvent.Invoke();
                //if (null != SavedHandleEvent.Target)
                //    Debug.Log("触发了事件" + "   " + SavedHandleEvent.Target);
                SavedHandleEvent = null;
            }
        }
    }
}